package com.common.controller;

import com.exp.model.Admin;
import com.exp.model.Business;
import com.exp.model.User;

import javax.servlet.http.HttpSession;

/**
 Created by P0063305 on 2016/3/30.
 */
public class BaseController {
 /*获取当前用户*/
 protected User getLoginUser(HttpSession session){
  User user=(User)session.getAttribute(Constant.SESSION_CURRENT_USER);
  return user;
 }
 /* 获取当前用户ID*/
 protected Integer getLoginUserId(HttpSession session) {
  return getLoginUser(session) == null ? null : getLoginUser(session).getId();
 }
 /*获取当前管理员*/
 protected Admin getLoginAdmin(HttpSession session){
  Admin admin=(Admin)session.getAttribute(Constant.SESSION_CURRENT_ADMIN);
  return admin;
 }
 /*获取当前管理员ID*/
 protected Integer getLoginAdminId(HttpSession session){
  return getLoginAdmin(session) ==null ? null: getLoginAdmin(session).getId();
 }
 /*获取当前商家*/
 protected Business getLoginBusiness(HttpSession session){
  Business business=(Business)session.getAttribute(Constant.SESSION_CURRENT_BUSINESS);
  return business;
 }
 /*获取当前商家ID*/
 protected Integer getLoginBusinessId(HttpSession session){
  return  getLoginBusiness(session)==null ? null:getLoginBusiness(session).getId();
 }
}
